<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //我们需要创建四大天王的对象 ，相同属性：名字 性别 年龄 相同的方法唱歌
        // function Star(name, sex, age) {
        //     this.name = name;
        //     this.sex = sex;
        //     this.age = age;
        //     this.sing = function (song) {
        //         console.log(song);
        //     }
        // }
        // var ldh = new Star('刘德华', '男', 18);
        // console.log(ldh.name);
        // console.log(ldh['sex']);
        // ldh.sing('宾语')
        // // console.log(typeof ldh);   //typeof 检测输出是不是ldh
        // var gfc = new Star('郭富城', '男', 20);
        // console.log(gfc.name);
        // console.log(gfc['sex']);
        // gfc.sing('八八')


        //练习
        function Hero(name, type, blood, attack) {
            this.name = name;
            this.type = type;
            this.blood = blood;
            this.attack = function (atck) {
                console.log(atck);
            }
        }
        var lianpo = new Hero('廉颇', '力量型', '500血量');
        console.log(lianpo.name);
        console.log(lianpo.type);
        console.log(lianpo.blood);
        lianpo.attack('近战')

        var hy = new Hero('后裔', '射手型', '100血量');
        console.log(hy.name);
        console.log(hy.type);
        console.log(hy.blood);
        lianpo.attack('远程')
    </script>

</head>

<body>

</body>

</html>